<template>
  <div class="app-container" v-loading="pageLoading">
    <el-button type="warning" class="fr mb-10" @click="deleteAll" v-permission="'adminSyslog.delete'">清空</el-button>
    <z-table :list="list" :tableProps="tableProps" :columns="columns" @editItem="editItem" @deleteItem="deleteItem">
      <template v-slot:operation="v">
        <a href="#" class="text-red" @click.prevent="deleteItem(v.row,v.$index)"
          v-permission="'adminSyslog.delete'">删除</a>
      </template>
    </z-table>
    <z-pagination :pagination="pagination" :total="total" :page.sync="query.page" :limit.sync="query.size"
      @change="getList"></z-pagination>
  </div>
</template>

<script>
import commonMixin from '@/views/_common/mixin'
export default {
  mixins: [commonMixin],
  components: {},
  name: 'adminSyslog',
  data: function () {
    return {
      api: this.$api.sysLog,
      name: '日志',
      columns: [
        { title: '日志类型', key: 'logger', width: 80 },
        { title: '日志等级', key: 'level', width: 80 },
        { title: '日志来源', key: 'url', width: 180 },
        { title: '请求方式', key: 'method', width: 80 },
        { title: '浏览器标识', key: 'user_agent', width: 180 },
        { title: 'Cookie', key: 'cookie', width: 100 },
        { title: '请求内容', key: 'request_body', width: 100 },
        { title: '日志信息', key: 'message' },
        { title: '请求耗时', key: 'elapsed', width: 90 },
        { title: 'IP来源', key: 'ip_address', width: 140 },
        { title: '创建人', key: 'create_user', width: 140 },
        { title: '创建时间', key: 'create_time', width: 140 },
      ],

      tableProps: {
        border: true,
        opsColWith: 60,
      },
      typeOptions: [],
    }
  },
  methods: {
    deleteAll() {
      this.$confirm('确认清空所有运行日志？')
        .then(() => {
          let url = this.api + 'deleteall'
          this.$request(url, {}, 'post').then((r) => {
            this.$message.success('操作成功')
            this.getList()
          })
        })
        .catch(() => {})
    },
  },
  created: function () {
    this.getList()
  },
}
</script>
<style scoped>
</style>
